﻿<DemoContainer>
    <ApexChart TItem="Order"
               Title="Order Net Value">

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Gross Value"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.GrossValue))"
                         OrderByDescending="e=>e.Y"
                         SeriesType="SeriesType.Bar"
                         DataPointMutator=SetGoals />


    </ApexChart>
</DemoContainer>

@code {
    private List<Order> Orders { get; set; } = SampleData.GetOrders();

    private void SetGoals(DataPoint<Order> datapoint)
    {
        datapoint.Goals = new();
        var goal = new DataPointGoal { Name = "Target" };
        datapoint.Goals.Add(goal);

        switch (datapoint.X.ToString())
        {
            case "France":
                goal.StrokeColor = "#e3001b";
                goal.StrokeDashArray = 5;
                goal.StrokeHeight = 5;
                goal.Value = 240000;
                break;

            case "Brazil":
                goal.StrokeColor = "#145A32";
                goal.StrokeHeight = 10;
                goal.Value = 290000;
                break;

            default:
                goal.StrokeColor = "#ffd500";
                goal.StrokeHeight = 13;
                goal.StrokeWidth = 0;
                goal.StrokeLineCap = LineCap.Round;
                goal.Value = 200000;
                break;
        }
    }
}
